package com.doit.demo.day02;

import org.apache.flink.api.java.tuple.Tuple5;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;


/**
 * @DATE 2022/2/14/9:12
 * @Author MDK
 * @Version 2021.2.2
 **/
public class MySqlDemo {
    public static void main(String[] args) throws Exception {

        /*'select name from tb_category where id=?'*/
        //1.创建flink,sql环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //2.调用socketTextStream创建DataStream
        DataStreamSource<String> lines = env.socketTextStream("linux01", 8888);

        //3.调用map输出结果
        SingleOutputStreamOperator<Tuple5<String, String, Integer, String, Double>> res = lines.map(new  MySqlFunction());

        //4.打印结果
        res.print();

        //5.启动程序
        env.execute();
    }
}
